using ViScript.Core.Argument;
using ViScript.Core.ParsedSentence;

namespace ViScript.Core.Argument
{
    public class ClauseArgument : IArgument
    {
        private readonly IParsedSentence parsedSentence;

        public ClauseArgument(IParsedSentence parsedSentence)
        {
            this.parsedSentence = parsedSentence;
        }

        public bool IsValid
        {
            get { return parsedSentence.IsValid; }
        }

        public object Value
        {
            get { return new Clause(delegate { parsedSentence.Execute(); }); }
        }

        public void Accept(IArgumentVisitor visitor)
        {
            visitor.VisitClauseArgument(this);
        }
    }
}